//package org.dromara.oce.utils;
//
//
//import cn.hutool.json.JSONUtil;
//import org.apache.http.HttpHost;
//import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
//import org.elasticsearch.action.support.master.AcknowledgedResponse;
//import org.elasticsearch.client.RequestOptions;
//import org.elasticsearch.client.RestClient;
//import org.elasticsearch.client.RestClientBuilder;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.elasticsearch.client.indices.CreateIndexRequest;
//import org.elasticsearch.client.indices.CreateIndexResponse;
//import org.elasticsearch.client.indices.GetIndexRequest;
//import org.elasticsearch.client.indices.GetIndexResponse;
//
//import java.io.IOException;
//
//public class ElasticSearchTest {
//
//
//    public static void main(String[] args) {
//        RestHighLevelClient client = new RestHighLevelClient(
//            RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
//        );
//
//        try {
//            //创建索引
//            CreateIndexRequest createIndexRequest = new CreateIndexRequest("hhl_index");
//            CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
//            boolean acknowledged = createIndexResponse.isAcknowledged();
//            System.out.println("索引操作状态：" + acknowledged);
//
//            // 2. 查询所有索引
////            GetIndexRequest request = new GetIndexRequest("hhl_index"); // 通配符 * 匹配所有索引
////            GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);
////            System.out.println("索引名称：" + response.getAliases());
////            System.out.println(response.getMappings());
////            System.out.println(response.getSettings());
//////            System.out.println(JSONUtil.toJsonStr(response.getIndices()));
//
//            //删除索引
////            DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("hhl_index");
////            AcknowledgedResponse delete = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
////            System.out.println(delete.isAcknowledged());
//
//
//            System.out.println(1);
//
//
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        } finally {
//            try {
//                client.close();
//            } catch (IOException e) {
//                throw new RuntimeException(e);
//            }
//        }
//
//
//    }
//}
